/**
 * 
 */
package fr.notoriousmaster.fury.lib.sensor;

import fr.notoriousmaster.fury.lib.camera.CameraView;
import fr.notoriousmaster.fury.lib.file.LibFile;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.view.View;
import android.widget.ImageView;

/**
 * @author PPECHE
 *
 */
public class BoulisteSensor {
	private SensorManager boulSensorManger;
	private BoulisteSensorListener boulSensorListener;
	
	/**
	 * @param context
	 */
	public BoulisteSensor(Context context, View view, CameraView cam, LibFile file) {
		boulSensorManger = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
		boulSensorListener = new BoulisteSensorListener(context,cam,file);
		boulSensorListener.setImgSensor((ImageView)view);
		boulSensorManger.registerListener(boulSensorListener, 
				boulSensorManger.getDefaultSensor(Sensor.TYPE_ORIENTATION),
				SensorManager.SENSOR_DELAY_UI);
	}
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#finalize()
	 */
	@Override
	public void finalize() {
		boulSensorManger.unregisterListener(boulSensorListener);
		boulSensorListener = null;		
		boulSensorManger = null;
	}
	
}
